package com.firebird.app.reader.pdf.adapter

import android.view.View
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder

import com.firebird.app.reader.R
import com.firebird.app.reader.pdf.bean.PDFFileInfo
import com.firebird.app.reader.pdf.util.PDFUtil

/**
 * @作者: ljk
 * @时间: 2019/1/11 20:31
 * @描述: pdf文件适配器类
 */
class PDFAdapter(data: List<PDFFileInfo>?) : BaseQuickAdapter<PDFFileInfo, BaseViewHolder>(R.layout.item_pdf, data) {
    override fun convert(helper: BaseViewHolder, item: PDFFileInfo) {
        if (item == null) {
            return
        }
        helper.setText(R.id.tv_name, item.getFileName())
        helper.setText(R.id.tv_size, PDFUtil.FormetFileSize(item.fileSize))
        helper.setText(R.id.tv_time, item.getTime())
        if (item.isSelect) {
            helper.getView<View>(R.id.img_select).setBackgroundResource(R.mipmap.reward_selection_ok)
        } else {
            helper.getView<View>(R.id.img_select).setBackgroundResource(R.mipmap.reward_selection_no)
        }
    }
}